package com.demo.android.endi.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;

import com.demo.android.endi.R;

public class EFilingAppListFragment extends ListFragment {
  	 
    String[] eFilingApp = new String[] {
        "Admin",
        "EFiling2",
        "Clerk2",
        "Court2"       
    };
    
    int[] health = new int[]{
    		R.drawable.sunny,
    		R.drawable.sunny,
    		R.drawable.raining,
    		R.drawable.sunny    			
    };   
    
 
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
		// Each row in the list stores websitename, webinfo and logo
        List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();        
        
        for(int i=0;i<4;i++){
        	HashMap<String, String> hm = new HashMap<String,String>();
            hm.put("app", eFilingApp[i]);
            hm.put("health", Integer.toString(health[i]));                     
            aList.add(hm);
        }
        
        // Keys used in Hashmap
        String[] from = { "app", "health" };
        
        // Ids of views in listview_layout
        int[] to = { R.id.appname, R.id.health};        
        
        // Instantiating an adapter to store each items
        // R.layout.listview_layout defines the layout of each item
        SimpleAdapter adapter = new SimpleAdapter(getActivity().getBaseContext(), aList, R.layout.fragment_section_apps, from, to);       
		
		setListAdapter(adapter);
		
		return super.onCreateView(inflater, container, savedInstanceState);		
   }
}
